package com.sayimo.maker.activity.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.sayimo.framework.database.mybatis.AbstractMybatisBaseDao;
import com.sayimo.framework.exception.DaoException;
import com.sayimo.maker.activity.dao.BaseCutDetailDao;
import com.sayimo.maker.activity.vo.BaseCutDetail;


/**
 * @Copyright (c) 2016 广东省尚一互联网有限公司
 * @Project: schoolmallapi-2.0
 * @ClassName: BaseCutDaoImpl.java
 * @Description: 砍价详情
 * @Author:	tanxin
 * @Date:2016年10月19日,上午11:47:07
 * @Version 1.0.0
 */
@Repository(value="baseCutDetailDao")
public class BaseCutDetailDaoImpl extends AbstractMybatisBaseDao<BaseCutDetail> implements BaseCutDetailDao{
	/**
	 * @Package com.sayimo.maker.activity.dao.impl
	 * @Author TANXIN
	 * @MethodName:selectBaseCutDetailByIdentifier
	 * @Description:根据标示符查询活动信息
	 * @param map
	 * @return
	 * @throws DaoException
	 * @Date 2016年10月20日,上午11:04:14
	 */
	@Override
	@SuppressWarnings({ "rawtypes"})
	public List<BaseCutDetail> selectBaseCutDetailByIdentifier(Map<String,Object> map)
			throws DaoException {
		
		return this.mybatisInterfaceBaseDao.query("com.sayimo.maker.activity.dao.BaseCutDetailDao.selectBaseCutDetailByIdentifier",map);
	}
	/**
	 * @Package com.sayimo.maker.activity.dao.impl
	 * @Author TANXIN
	 * @MethodName:selectBaseCutDetailJoinByCustomerId
	 * @Description:根据会员id查询砍价活动参与人信息
	 * @param map
	 * @return
	 * @throws DaoException
	 * @Date 2016年10月20日,上午11:04:11
	 */
	@Override
	@SuppressWarnings({ "rawtypes"})
	public List<BaseCutDetail> selectBaseCutDetailJoinByCustomerId(Map<String,Object> map)
			throws DaoException {
		
		return this.mybatisInterfaceBaseDao.query("com.sayimo.maker.activity.dao.BaseCutDetailDao.selectBaseCutDetailJoinByCustomerId",map);
	}
	/**
	 * @Package com.sayimo.maker.activity.dao.impl
	 * @Author TANXIN
	 * @MethodName:addCutDetail
	 * @Description:发起人发起砍价插入砍价详情表
	 * @param baseCutDetail
	 * @return
	 * @throws DaoException
	 * @Date 2016年10月20日,下午2:12:03
	 */
	@Override
	public Integer addCutDetail(BaseCutDetail baseCutDetail)
			throws DaoException {
		// TODO Auto-generated method stub
		return this.mybatisInterfaceBaseDao.insert("com.sayimo.maker.activity.dao.BaseCutDetailDao.addCutDetail",baseCutDetail);
	}
	/**
	 * @Package com.sayimo.maker.activity.dao.impl
	 * @Author TANXIN
	 * @MethodName:addCutJoin
	 * @Description:参与人点击砍价，记录插入t_base_cut_join表
	 * @param baseCutDetail
	 * @return
	 * @throws DaoException
	 * @Date 2016年10月20日,下午3:11:28
	 */
	@Override
	public Integer addCutJoin(BaseCutDetail baseCutDetail)
			throws DaoException {
		// TODO Auto-generated method stub
		return this.mybatisInterfaceBaseDao.insert("com.sayimo.maker.activity.dao.BaseCutDetailDao.addCutJoin",baseCutDetail);
	}
	/**
	 * @Package com.sayimo.maker.activity.dao.impl
	 * @Author TANXIN
	 * @MethodName:updateCutDetail
	 * @Description:修改砍价详情信息
	 * @param baseCutDetail
	 * @return
	 * @throws DaoException
	 * @Date 2016年10月20日,下午3:24:17
	 */
	@Override
	public Integer updateCutDetail(BaseCutDetail baseCutDetail)
			throws DaoException {
		// TODO Auto-generated method stub
		return this.mybatisInterfaceBaseDao.update("com.sayimo.maker.activity.dao.BaseCutDetailDao.updateCutDetail",baseCutDetail);
	}
	/**
	 * @Package com.sayimo.maker.activity.dao.impl
	 * @Author TANXIN
	 * @MethodName:getCustomerCutPriceGoodsBuy
	 * @Description:获取会员在该砍价活动购买商品总数
	 * @param customerId
	 * @param identifier
	 * @return
	 * @throws DaoException
	 * @Date 2017年1月6日,上午10:36:53
	 */
	@Override
	public Integer getCustomerCutPriceGoodsBuy(Integer customerId,
			String identifier) throws DaoException {
		Map<String,Object> paramMap = new HashMap<>();
		paramMap.put("customerId", customerId);
		paramMap.put("identifier", identifier);
		return this.mybatisInterfaceBaseDao.queryCount("com.sayimo.maker.activity.dao.BaseCutDetailDao.getCustomerCutPriceGoodsBuy", paramMap);
	}
	@Override
	public Integer getPreCustomerCutPriceGoodsBuy(Integer customerId,
			String identifier) throws DaoException {
		Map<String,Object> paramMap = new HashMap<>();
		paramMap.put("customerId", customerId);
		paramMap.put("identifier", identifier);
		return this.mybatisInterfaceBaseDao.queryCount("com.sayimo.maker.activity.dao.BaseCutDetailDao.getPreCustomerCutPriceGoodsBuy", paramMap);
	}

}
